package vcp.gui.guest.screens;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.TitledBorder;
import vcp.gui.components.VCPMenu;
import vcp.gui.components.VCPPanel;
import vcp.gui.forms.LoginForm;
import vcp.gui.utils.MenuBuilder;


public class ScreenMain extends VCPPanel {
	private VCPPanel pnlLeft;
	private VCPPanel pnlRight;
	private MenuBuilder menu;	
	private LoginForm login;	
	private GroupLayout groupLayout;	
	/**
	 * Create the panel.
	 * @param vcpMenu 
	 */
	public ScreenMain(VCPMenu vcpMenu) {		
		pnlLeft = new VCPPanel();
		pnlLeft.setBorder(new TitledBorder(null, "Customers", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		pnlRight = new VCPPanel();
		pnlRight.setBorder(new TitledBorder(null, "Staff", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		
		pnlLeft.add(vcpMenu);		
		login = new LoginForm();
		initLayout();
	}	
	
	private void initLayout(){
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(pnlLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(pnlRight, GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addComponent(pnlRight, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
						.addComponent(pnlLeft, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE))
					.addContainerGap())
		);
		GroupLayout gl_pnlRight = new GroupLayout(pnlRight);
		gl_pnlRight.setHorizontalGroup(
			gl_pnlRight.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlRight.createSequentialGroup()
					.addContainerGap()
					.addComponent(login, GroupLayout.PREFERRED_SIZE, 260, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(33, Short.MAX_VALUE))
		);
		gl_pnlRight.setVerticalGroup(
			gl_pnlRight.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_pnlRight.createSequentialGroup()
					.addContainerGap()
					.addComponent(login, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(113, Short.MAX_VALUE))
		);
		pnlRight.setLayout(gl_pnlRight);
		setLayout(groupLayout);
	}

	public GroupLayout getGroupLayout() {
		return groupLayout;
	}

	public void setGroupLayout(GroupLayout groupLayout) {
		this.groupLayout = groupLayout;
	}
}
